package co.yixiang.hw.service;

import co.yixiang.hw.domain.YxStoreCouponUser;
import co.yixiang.hw.service.dto.YxStoreCouponUserDto;
import co.yixiang.hw.service.dto.YxStoreCouponUserQueryCriteria;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;

import java.util.Map;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

/**
* @author Walert
* @date 2020-03-10
*/
public interface YxStoreCouponUserService {

    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable);

    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<YxStoreCouponUserDto>
    */
    List<YxStoreCouponUserDto> queryAll(YxStoreCouponUserQueryCriteria criteria);

    /**
     * 根据ID查询
     * @param id ID
     * @return YxStoreCouponUserDto
     */
    YxStoreCouponUserDto findById(Integer id);

    /**
    * 创建
    * @param resources /
    * @return YxStoreCouponUserDto
    */
    YxStoreCouponUserDto create(YxStoreCouponUser resources);

    /**
    * 编辑
    * @param resources /
    */
    void update(YxStoreCouponUser resources);

    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Integer[] ids);

    /**
     * 保存用户优惠券记录
     * @param params
     */
    @Async
    void saveCouponUser(JSONObject params);


    /**
     * 获取用户可用优惠券
     * @param uid
     * @param goodsId
     * @return
     */
    List<YxStoreCouponUser> getUserCanUseCouponList(Integer uid, Integer goodsId);

    /**
     * 获取用户可用优惠券
     * @param uid
     * @return
     */
    List<Map> getUserCanUseCouponListV2(Integer uid);

    @Async
    void useCoupon(Integer userCouponId, String orderNum);

    @Async
    void useCouponByOrderId(Integer orderId, String orderNum);
}